//===============================================================================
// XGenPlus Tool
// ==============================================================================
// Please visit http://www.codeplex.com/xgenplus for latest updates.
//
// This source is subject to the GNU General Public License v2.
// 
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace XGenPlus
{
    /// <summary>
    /// To parse the arguments
    /// </summary>
    class ArgumentHelper
    {
        public static bool ArgumentMatch(string arg, string formal)
        {
            if ((arg[0] == '/') || (arg[0] == '-'))
            {
                arg = arg.Substring(1);
                if (arg == formal)
                {
                    return true;
                }
                if (arg.Length == 1)
                {
                    return (arg[0] == formal[0]);
                }
            }
            return false;

        }



        public static bool ArgumentMatchEx(string arg, string formal, int minletters)
        {


            if ((arg[0] == '/') || (arg[0] == '-'))
            {
                arg = arg.Substring(1);
                if (arg.Length < minletters || formal.Length < minletters) return false;
                return (formal.Substring(0,minletters)==arg.Substring(0,minletters));
            }
            return false;
        }

        public static void ParseList(string value, List<string> list)
        {
            if (value.Length > 0)
            {
                string[] strArray = value.Split(new char[] { ',' });
                for (int i = 0; i < strArray.Length; i++)
                {
                    string str = strArray[i].Trim();
                    if ((str != null) && (str.Length != 0))
                    {
                        list.Add(str);
                    }
                }
            }
        }

    }
}
